;;; config.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;

;;; Code:
(use-package anzu
  :ensure t
  :defer t
  :bind (("M-%" . anzu-query-replace)
         ("C-M-%" . anzu-query-replace-regexp))
  :init (global-anzu-mode)
  :config
  (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)

  (defun cfg:anzu-update-func (here total)
    (when anzu--state
      (let ((status (cl-case anzu--state
                      (search (format "[%d/%d Seek]" here total))
                      (replace-query (format "(%d Replaces)" total))
                      (replace (format "[%d/%d Replaces]" here total)))))
        (propertize status 'face 'anzu-mode-line))))

  (setq anzu-cons-mode-line-p nil
        anzu-mode-lighter ""
        anzu-deactivate-region t
        anzu-search-threshold 1000
        anzu-replace-threshold 50
        anzu-replace-to-string-separator " => "
        anzu-mode-line-update-function #'cfg:anzu-update-func)

  (add-to-list 'minor-mode-alist
               '(:eval (when anzu--state
                         (concat " " (anzu--update-mode-line))))))

(provide 'config)
;;; config.el ends here
